#!/usr/bin/env python
# encoding: utf-8
"""
@author: youfeng
@email: youfeng243@163.com
@license: Apache Licence
@file: delete_table.py
@time: 2017/12/30 17:42
"""

import sys

sys.path.append('..')
from common.table_manage import TableManage
from common.mongo import MongDb
from logger import Logger

MONGO_DB_SOURCE = {
    'host': '172.16.215.2',
    'port': 40042,
    'db': 'company_data',
    'username': 'work',
    'password': 'haizhi'
}

# 日志模块
log = Logger('delete_table.log').get_logger()

source_db = MongDb(MONGO_DB_SOURCE['host'], MONGO_DB_SOURCE['port'], MONGO_DB_SOURCE['db'],
                   MONGO_DB_SOURCE['username'],
                   MONGO_DB_SOURCE['password'], log=log)

# 省份信息
PROVINCE_LIST = [
    'gansu',
    'hunan',
    'beijing',
    'tianjin',
    'hebei',
    'shandong',
    'guangxi',
    'qinghai',
    'jiangsu',
    'ningxia',
    'sichuan',
    'liaoning',
    'guangdong',
    'jilin',
    'shanxi',
    'anhui',
    'shanghai',
    'xizang',
    'hainan',
    'shanxicu',
    'neimenggu',
    'yunnan',
    'hubei',
    'zhejiang',
    'heilongjiang',
    'chongqing',
    'xinjiang',
    'henan',
    'guizhou',
    'fujian',
    'jiangxi',
]


def main():
    for province in PROVINCE_LIST:
        table_name = TableManage.get_seed_table(province)
        source_db.drop(table_name)

        table_name = TableManage.get_param_table(province)
        source_db.drop(table_name)


if __name__ == '__main__':
    main()
